(function (angular) {
    'use strict';
    angular.module("fs.logger").provider("loggerFactory", loggerFactory);
    loggerFactory.$inject = ['logEnhancerProvider'];
    function loggerFactory(logEnhancerProvider) {
        var provider = this;
        provider.LEVEL = {
            TRACE: 4,
            DEBUG: 3,
            INFO: 2,
            WARN: 1,
            ERROR: 0,
            OFF: -1
        };
        provider.setPrefixPattern = function () {
            logEnhancerProvider.prefixPattern = '[%s - %s - %s]: ';
        };
        provider.setDatetimePattern = function () {
            logEnhancerProvider.datetimePattern = 'hh:mm:ss';
        };
        provider.setLogLevels = function (logLevels) {
            logEnhancerProvider.logLevels = logLevels;
        };
        this.$get = ['$log', function ($log) {
            return {
                LEVEL: provider.LEVEL,
                getLogger: function (instance) {
                    return instance ? $log.getInstance(instance) : $log.getInstance('global')
                },
                setLevel: function (level, instance) {
                    (instance && instance !== '*') ? ($log.logLevels[instance] = level) : ($log.logLevels['*'] = level);
                }
            };
        }];
    }
})(angular);